//
//  DetailInfoCell.swift
//  Employee
//
//  Created by swordjoy on 2017/3/28.
//  Copyright © 2017年 remotevillage. All rights reserved.
//

import UIKit

class DetailInfoCell: UITableViewCell {
  static var identifier = "DetailInfoCell.swordjoy"
  
  static func height(with content: String) -> CGFloat {
    return 68 + UIFont.calculateHeight(width: UIScreen.width - 60, font: GlobalConfig.system16Font, text: content)
  }
  
  var model: OrderDetailModel? {
    
    didSet {
      
      guard let temp = model else { return }
      
      if "" == temp.content {
        detailLabel.text = "无"
      } else {
        detailLabel.text = temp.content
      }
      
    }
    
  }
  
  fileprivate var titleLabel: UILabel!
  fileprivate var detailLabel: UILabel!
  
  // MARK: - life cycle
  override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    
    selectionStyle = .none
    
    backgroundColor = UIColor.white
    create()
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
}

// MARK: - fileprivate

extension DetailInfoCell {
  fileprivate func create() {
    titleLabel = UILabel()
    contentView.addSubview(titleLabel)
    titleLabel.font = GlobalConfig.system12Font
    titleLabel.textColor = GlobalConfig.TextLightColor
    titleLabel.text = "工单描述"
    titleLabel.snp.makeConstraints { (make) in
      make.left.equalTo(20)
      make.top.equalToSuperview()
    }
    
    detailLabel = UILabel()
    contentView.addSubview(detailLabel)
    detailLabel.font = GlobalConfig.system16Font
    detailLabel.textColor = GlobalConfig.TextDeepColor
    detailLabel.numberOfLines = 0
    detailLabel.snp.makeConstraints { (make) in
      make.left.equalTo(20)
      make.top.equalTo(titleLabel.snp.bottom).offset(15)
      make.right.equalTo(-40)
    }
  }
}
